package com.qianclass.talklive.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.qianclass.talklive.R;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/9/11.
 */

public class EmojiAdapter extends BaseAdapter {

    private Context mContext;
    private List<Map<String, Object>> mEmojiLists;

    public EmojiAdapter(Context context, List<Map<String, Object>> emojiLists) {
        mContext = context;
        mEmojiLists = emojiLists;
    }

    @Override
    public int getCount() {
        return mEmojiLists != null ? mEmojiLists.size() : 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_emoji, null);
            holder = new ViewHolder();
            holder.ivItemEmoji = (ImageView) convertView.findViewById(R.id.iv_item_emoji);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.ivItemEmoji.setImageResource((Integer) mEmojiLists.get(position).get("image"));

        return convertView;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    class ViewHolder {
        ImageView ivItemEmoji;
    }
}
